package com.tre.jdevtemplateboot.web.controller;


import com.tre.jdevtemplateboot.common.dto.ResponseResult;
import com.tre.jdevtemplateboot.domain.dto.SpAppMstDto;
import com.tre.jdevtemplateboot.domain.vo.SpAppMstListVO;
import com.tre.jdevtemplateboot.domain.vo.SpAppMstVO;
import com.tre.jdevtemplateboot.service.ISpAppMstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author JDev
 * @since 2023-11-15
 */
@RestController
@RequestMapping("/app")
public class SpAppMstController {

    @Autowired
    private ISpAppMstService spAppMstService;

    /**
     * 查询所有app
     *
     * @return
     */
    @PostMapping
    public ResponseResult<SpAppMstListVO> list() {
        return spAppMstService.findAll();
    }

    /**
     * 根据id查询app
     * @return
     */
    @PostMapping
    public ResponseResult<SpAppMstVO> findById(String id) {
        return spAppMstService.getSpAppById(id);
    }

    /**
     * 新增app
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody SpAppMstDto dto) {
        return spAppMstService.saveApp(dto);
    }

    /**
     * 修改app
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody SpAppMstDto dto) {
        return spAppMstService.updateApp(dto);
    }

    /**
     * 删除app
     * @param id
     * @return
     */
    @PostMapping("/del")
    public ResponseResult delete(String id){
        return spAppMstService.delete(id);
    }


}


